package com.as3.timbot.mvc
{
	import flash.events.EventDispatcher;
	import com.as3.timbot.events.AppDispatcher;///create this....t.w.
	import flash.events.Event;
	import com.as3.timbot.mvc.Plugin;
	import com.as3.timbot.helper.Helper;
	/**
	 * The Plugin will be injected into another object via constructor or setter 
	 * dependency injection.  It's role is to give functionality to the view or
	 * model, while at the same time being fully swappable
	 * The AbstractPlugin provide the basic functionality to broadcast events
	 * publicly, privately, and application wide
	 * 
	 * Extend this class to provide specific functionality to any view
	 * */
	
	public class AbstractPlugin implements Plugin
	{
		
		private var privateChannel:EventDispatcher;
		private var publicChannel:EventDispatcher;
		//public static var applicationChannel:EventDispatcher;
		
		private var __helper:Helper;
		
		public function AbstractPlugin()
		{
			super();
			privateChannel = new EventDispatcher();
			publicChannel = new EventDispatcher();
		}
		public function firePrivateEvent(ev:Event):void
		{
			privateChannel.dispatchEvent(ev);
		}
		public function firePublicEvent(ev:Event):void
		{
			publicChannel.dispatchEvent(ev);
		}
		public function addPrivateEventListener(ev:String,handler:Function):void
		{
			privateChannel.addEventListener(ev,handler);
		}
		public function addPublicEventListener(ev:String,handler:Function):void
		{
			publicChannel.addEventListener(ev,handler);
		}
		public function setView(value:Helper):void
		{
			__helper = value;
			register();
		}
		public function getView():Helper
		{
			return __helper;
		}
		protected function register():void
		{
			
		}
	}
}